package com.dwy2002.order;


import com.dwy2002.common.Result;
import com.dwy2002.common.annotation.RequiresPermission;
import com.dwy2002.enums.Logical;
import com.dwy2002.order.service.IPaymentRecordsService;
import com.dwy2002.pojo.dto.order.RefundStatusEnableRequestDTO;
import com.dwy2002.pojo.vo.order.PaymentRecordsVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author 杜伟毅
 * @version 1.0
 * @since 2025/03/14
 */
@RestController
@RequestMapping("/paymentRecords")
@RequiredArgsConstructor
public class PaymentRecordsController {
    private final IPaymentRecordsService service;

    /**
     * 更新单个订单变为可退款
     *
     * @author 杜伟毅
     * @since 2025/3/14 0014 23:43
     */
    @RequiresPermission(value = {"A8"}, logical = Logical.OR)
    @PostMapping("/refundStatus")
    public Result<Void> generateOrder(@RequestBody RefundStatusEnableRequestDTO dto) {
        return service.enableRefundStatus(dto);
    }

    /**
     * 返回该订单是否为不可退款
     *
     * @param id 订单id
     * @author 杜伟毅
     * @since 2025/5/11 0011 16:54
     */
    @RequiresPermission(value = {"A8"}, logical = Logical.OR)
    @GetMapping("/{id}")
    public Result<PaymentRecordsVO> getIsRefundable(@PathVariable String id) {
        return service.getIsRefundable(id);
    }
}
